package cn.ruituo.adv6;

import java.util.Objects;

public class Pig {
    private String name;
    private int age;
    private int weight;

    public Pig(String name){
        this.name=name;
    }
    private Pig(String name, int age, int weight) {
        this.name = name;
        this.age = age;
        this.weight = weight;
    }
    private void shoutTo(String ghost){
        System.out.println(ghost+"，你这个妖怪，吃我老猪一钉耙");
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || this.getClass() != o.getClass()) return false;
        Pig pig = (Pig) o;
        return Objects.equals(name, pig.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }

    @Override
    public String toString() {
        return "这是一只猪{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", weight=" + weight +
                '}';
    }
}
